package ru.susu.algebra.iterators;

import java.util.Iterator;

/**
 * @author akargapolov
 * @since: 15.07.2010
 */
public class SimpleForIntegerIterator implements Iterator<Integer>, Cloneable
{
	private int _start;
	private int _end;
	private int _increment;
	private int _current;

	public SimpleForIntegerIterator(int start, int end, int increment)
	{
		_start = start;
		_end = end;
		_increment = increment;
		_current = _start;
	}

	@Override
	public boolean hasNext()
	{
		return _current <= _end;
	}

	@Override
	public Integer next()
	{
		int result = _current;
		_current += _increment;
		return result;
	}

	@Override
	public void remove()
	{
		throw new RuntimeException("Unsupported method");
	}

	@Override
	public Object clone()
	{
		return new SimpleForIntegerIterator(_start, _end, _increment);
	}
}
